package leetcode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class chengshuirongqi {

    public List<Integer> list=new ArrayList<>();
    public int maxArea(int[] nums) {
        int end=nums.length-1;
        int  start=0;
        int v=0;
        while(start!=end){
            if(nums[start]<=nums[end]){
                v=nums[start]*(end-start);
                list.add(v);
                start++;
            }else{
                v=nums[end]*(end-start);
                list.add(v);
                end--;
            }
        }
        int max=Collections.max(list);
        return max;

    }
    public static void main(String[] args) {

       int[] nums={1,8,6,2,5,4,8,3,7};
       chengshuirongqi chengshuirongqi=new chengshuirongqi();
       int m=chengshuirongqi.maxArea(nums);
       //注意我直接调用chengshuirongqi.list
        //如果我在main方法里面新创建一个list，sout(list)此时为空
        System.out.println(chengshuirongqi.list);
        System.out.println(m);


    }
}
